//package com.jsh.erp.task;
//
//import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.toolkit.StringUtils;
//import com.jsh.erp.datasource.entities.Supplier;
//import com.jsh.erp.datasource.entities.User;
//import com.jsh.erp.datasource.mappers.AccountHeadMapper;
//import com.jsh.erp.datasource.mappers.SupplierMapper;
//import com.jsh.erp.datasource.mappers.SynchronizationTaskMapperEx;
//import com.jsh.erp.service.accountHead.AccountHeadService;
//import com.jsh.erp.service.user.UserService;
//import com.jsh.erp.utils.GetUtil;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.math.BigDecimal;
//import java.util.Date;
//import java.util.List;
//
///**
// * @author wy
// * @title: AllTask
// * @projectName JSH_ERP
// * @description:
// * @date 2023-03-29 19:50
// */
//@Component
//@Configuration
//@EnableScheduling
//public class AllTask {
//
//
//    @Resource
//    private SynchronizationTaskMapperEx synchronizationTaskMapperEx;
//    @Resource
//    private AccountHeadService accountHeadService;
//    @Resource
//    private SupplierMapper supplierMapper;
//
//    @Resource
//    private UserService userService;
//
////    @Scheduled(cron = "0/15 * * * * ?")  //每15秒执行一次
//    @Scheduled(cron = "0 0/30 * * * ?")
//    public void getBasicDataTask() throws Exception {
//        User user = userService.getManager();
//        if (user != null) {
//            String remark = user.getRemark();
//            if (StringUtils.isEmpty(remark)){
//                List<Supplier> oldSuppliers = synchronizationTaskMapperEx.findBySelectNotTenant_cus("客户");
//                if (oldSuppliers!= null && oldSuppliers.size()>0){
//                    for (Supplier oldEntity : oldSuppliers) {
//                        BigDecimal changeAmount = accountHeadService.getAdvanceInBySupplierId(oldEntity.getId(),"预收款");
//                        BigDecimal payAmount = accountHeadService.getPayAdvanceInBySupplierId(oldEntity.getId(),"收款");
//                        oldEntity.setUploadFlag("0");
//                        oldEntity.setUpdateTime(new Date());
//                        BigDecimal subtract = changeAmount.subtract(payAmount);
//                        BigDecimal advanceIn = oldEntity.getAdvanceIn();
//                        if (subtract != null && advanceIn != null && subtract.compareTo(advanceIn) != 0){
//                            oldEntity.setAdvanceIn(subtract);
//                            synchronizationTaskMapperEx.updateSupplierEntity(oldEntity);
//                        }
//
//                    }
//                }
//            }
//        }
//    }
//
//
//    public static void main(String[] args) {
//        BigDecimal zero=BigDecimal.ZERO;
//        BigDecimal zero55=new BigDecimal("-1");
//        if (zero.compareTo(zero55) > 0){
//            System.out.println("进入");
//        }else {
//            System.out.println("未进入");
//        }
//    }
//}
